package com.agile.leetcode.niuke;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @Author:ChenZhangKun
 * @Date: 2021/1/6 19:37
 */
public class Demo2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String next = scanner.next();
        int max = 0;
        String[] result = new String[2];
        // 遍历字符串
        char[] chars = next.toCharArray();

        for (int i = 0; i < chars.length; i++) {
            StringBuilder builder = new StringBuilder();
            if (chars[i] == '(') {
                // 非法
                if (chars[i + 1] == '0') {
                    continue;
                }
                int j = i + 1;
                while (chars[j] != ',') {

                    builder.append(chars[j]);
                    j++;
                }
                builder.append(",");
                if (chars[j + 1] == '0') {
                    continue;
                }
                int m = j;
                while (chars[m + 1] != ')') {
                    builder.append(chars[m + 1]);
                    m++;
                }
                String[] split = builder.toString().split(",");

                // 计算值
                int i1 = Integer.parseInt(split[0]);
                int i2 = Integer.parseInt(split[1]);
                if (i1 * i1 + i2 * i2 * i2 > max) {
                    max = i1 * i1 + i2 * i2 * i2;
                    result[0] = split[0];
                    result[1] = split[1];
                }
            }
        }
        if (result[0]==null||result[1]==null){
            System.out.println("(0,0)");
        }else {
            System.out.println("("+result[0]+","+result[1]+")");
        }

    }
}
